<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>后台管理 - 易买网</title>
    <link type="text/css" rel="stylesheet" href="../css/style.css"/>
    <script type="text/javascript" src="../scripts/function-manage.js"></script>
    <script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
    <style type="text/css">
        a{
            font-size: 14px;
        }
    </style>
</head>
<body>
<div id="header" class="wrap">
    <div id="logo"><img src="../images/logo.gif"/></div>
    <div class="help"><a href="../index.html">返回前台页面</a></div>
    <div class="navbar">
        <ul class="clearfix">
            <li><a href="index.html">首页</a></li>
            <li><a href="user.html">用户</a></li>
            <li class="current"><a href="product.html">商品</a></li>
            <li><a href="order.html">订单</a></li>
            <li><a href="guestbook.html">留言</a></li>
            <li><a href="news.html">新闻</a></li>
        </ul>
    </div>
</div>
<div id="childNav">
    <div class="welcome wrap">
        管理员pillys您好，今天是2012-12-21，欢迎回到管理后台。
    </div>
</div>
<div id="position" class="wrap">
    您现在的位置：<a href="index.html">易买网</a> &gt; 管理后台
</div>
<div id="main" class="wrap">
    <div id="menu-mng" class="lefter">
        <div class="box">
            <dl>
                <dt>用户管理</dt>
                <dd><em><a href="user-add.html">新增</a></em><a href="user.html">用户管理</a></dd>
                <dt>商品信息</dt>
                <dd><em><a href="productClass-add.html">新增</a></em><a href="productClass.html">分类管理</a></dd>
                <dd><em><a href="product-add.html">新增</a></em><a href="product.html">商品管理</a></dd>
                <dt>订单管理</dt>
                <dd><a href="order.html">订单管理</a></dd>
                <dt>留言管理</dt>
                <dd><a href="guestbook.html">留言管理</a></dd>
                <dt>新闻管理</dt>
                <dd><em><a href="news-add.html">新增</a></em><a href="news.html">新闻管理</a></dd>
            </dl>
        </div>
    </div>
    <div class="main">
        <h2>商品管理</h2>
        <div class="manage">
            <table class="list">
                <tr>
                    <th>ID</th>
                    <th>商品名称</th>
                    <th>操作</th>
                </tr>
            </table>
            <a href="javascript:void(0)" class="pages" id="first">首页</a>|
            <a href="javascript:void(0)" class="pages" id="prevPage">上一页</a>|
            当前页:<span id="current"></span></li>|
            <a href="javascript:void(0)" class="pages" id="nextPage">下一页</a>|
            <a href="javascript:void(0)" class="pages" id="lastPage">末页</a>
        </div>
    </div>
    <div class="clear"></div>
</div>
<div id="footer">
    Copyright &copy; 2010   北大青鸟 All Rights Reserved. 京ICP证1000001号
</div>
</body>
</html>
<script>
    var prevPageNo=null;
    var nextPageNo=null;
    var pageNo=null;
    var totalPages=null;
    $(function () {
        var getList = function (current) {
            $.ajax({
                type: "POST",
                url: "../AllProductServlet",
                dataType: "JSON",
                data: {
                    pageNo: current || 1,
                },
                success: function (data) {
                    $(".newtr").remove();
                    $.each(data.items, function (index, obj) {
                        var newtr = "<tr class='newtr'><td class='first w4 c'>" + obj.productid + "</td><td class='thumb'><img src='../images/product/" + obj.pic + "' width='40px'><a href='../product-view.jsp' target='_blank'>" + obj.productname + "</a></td><td class='w1 c'><a href='product-view.jsp?productid="+obj.productid+"'>查看</a>|<a href='product-modify.jsp?productid="+obj.productid+"'>修改</a>|<a href='../DeleteProductServlet?productid="+obj.productid+"' onclick='return confirmdel();'>删除</a></td></tr>";
                        $(".list").append(newtr);
                        prevPageNo = data.prevPageNo;
                        nextPageNo = data.nextPageNo;
                        pageNo = data.pageNo;
                        totalPages = data.totalPage;
                    })
                }
            })
        }
        getList();
        $(".pages").click(function () {
            var idvale=$(this).attr("id");
            if(idvale=="prevPage"){
                getList(prevPageNo);
            }else if(idvale=="first"){
                getList(1);
            }else if(idvale=="lastPage"){
                getList(totalPages);
            }else{
                getList(nextPageNo);
            }
        });
    });

    function confirmdel() {
        var flag=confirm("是否删除？");
        if(flag){
            return true;
        }else {
            return false;
        }
    }
</script>
